package com.jyw.business.ins.wechat.controller;

import com.jyw.business.ast.domain.dto.web.InsRectifyAstPageDto;
import com.jyw.business.ast.domain.dto.wechat.WechatInsRectifyAstPageDto;
import com.jyw.business.ast.domain.vo.web.InsRectifyAstPageVo;
import com.jyw.business.ins.domain.dto.web.RectifyDto;
import com.jyw.business.ins.domain.dto.web.RectifyUnitPageDto;
import com.jyw.business.ins.domain.dto.web.TransmitDto;
import com.jyw.business.ins.domain.dto.wechat.WechatRectifyUnitPageDto;
import com.jyw.business.ins.domain.vo.web.RectifyDetailVo;
import com.jyw.business.ins.domain.vo.web.RectifyUnitPageVo;
import com.jyw.business.ins.service.IInsTaskRectifyService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import com.jyw.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 巡检任务整改Controller
 * 
 * @author system
 * @date 2023-10-07
 */
@RestController
@RequestMapping("wechat/ins/rectify")
@Api(tags = "异常整改")
public class WechatInsTaskRectifyController extends BaseController
{

    @Resource
    private IInsTaskRectifyService taskRectifyService;

    /**
     * 资产查询
     */
    @PreAuthorize("@ss.hasPermi('ins:rectify:list')")
    @PostMapping("/ast/list")
    @ApiOperation("资产查询")
    public TableDataInfo<InsRectifyAstPageVo> astList(BasePage page, @RequestBody WechatInsRectifyAstPageDto dto)
    {
        if(!ObjectUtils.isEmpty(page)){
            startPage();
        }
        List<InsRectifyAstPageVo> list = taskRectifyService.wxRectifyAstList(dto);
        return getDataTable(list);
    }

    /**
     * 巡检单元查询
     */
    @PreAuthorize("@ss.hasPermi('ins:rectify:list')")
    @PostMapping("/unit/list")
    @ApiOperation("巡检单元查询")
    public TableDataInfo<RectifyUnitPageVo> unitList(BasePage page, @RequestBody WechatRectifyUnitPageDto dto)
    {
        if(!ObjectUtils.isEmpty(page)){
            startPage();
        }
        List<RectifyUnitPageVo> list = taskRectifyService.wxRectifyUnitList(dto);
        return getDataTable(list);
    }

    /**
     * 整改详情
     */
    @PreAuthorize("@ss.hasPermi('ins:rectify:detail')")
    @GetMapping("/detail/{id}")
    @ApiOperation("整改详情")
    public CommonResult<RectifyDetailVo> detail(@PathVariable("id")Long id)
    {
        RectifyDetailVo vo = taskRectifyService.getRectifyDetail(id);
        return CommonResult.success(vo);
    }
    /**
     * 提交整改
     */
    @PreAuthorize("@ss.hasPermi('ins:rectify:rectify')")
    @PutMapping("rectify")
    @ApiOperation("整改")
    public CommonResult rectify(@RequestBody @Valid RectifyDto dto){
        taskRectifyService.rectify(dto);
        return CommonResult.success("提交成功");
    }

}
